<meta charset="utf-8"/>
<link rel="stylesheet" href="style/calendrier.css" type="text/css" media="screen" />

<script type="text/javascript" src="modeles/jquery.js"></script>
<script type ="text/javascript" src="modeles/javascriptFonctions.js"></script>
<script type ="text/javascript" src="modeles/calendrier.js"></script>

<h2>Fiche action</h2>

<?php
	if(isset($_SESSION["erreur"]))
	{
		foreach($_SESSION["erreur"] as $e)
		{
			echo $e."</br>";
		}
		unset($_SESSION["erreur"]);
	}

echo '<br/>
<form action="index.php?module=actionComm&amp;action=detail&amp;'.ID_ADC.'='.$_GET[ID_ADC].'&retour='.$_GET["retour"].'" method="post" >';

echo'<hr class="trait"/>';
if($adc->get_groupableForum()==0)
{
	echo'<table id="tabTaches">
		<th><h4>Tâches</h4></th>
			<tr>
				<th class="BPlus">
					<input type="button" name="Plus" value="+" onClick="ajoutTache()"/>
				</th>
				<th>
					<label for="TacheRealise">Tâches réalisées</label>
				</th>
				<th>
					<label for="Echeance">Echéance</label>
				</th>
				<th>
					<label for="Responsable">Responsable</label>
				</th>
				<th></th>
			</tr>';
				$etuConnect= new Etudiants($_SESSION["loginUser"]);
				$etuConnect->getOneEtudiant();
				$premiere = true;
				
				foreach($t as $ta)
				{
					$idtache[] = $ta->get_id();
					echo '<tr>
					 	  <td></td>
					 	  <td class="TabT">
					 	  <input type="text" name="TacheRealise[]" ';
					
				 	echo 'class="obligatoire" value="'.$ta->get_libelle().'" onBlur="verifChamp(this)" onFocus="blanc(this)"/>
						  </td>
						  <td class="TabT">
				 		  <input type="text" name="Echeance[]" ';
					
					echo 'value="'.$ta->get_echeance().'" placeholder="jj/mm/aaaa" class="calendrier"/>
						  </td>
						  <td class="TabT">
						  <div id="for">
						  <select class="obligatoire" name="Responsable[]">';
					
					echo '<option selected value="'.$ta->get_id_etudiant().'">'.$ta->get_etudiant()->get_nom().' '.$ta->get_etudiant()->get_prenom().'</option>';
					foreach($adc->get_etudiants_ADC() as $etu)
					{
						if($ta->get_id_etudiant() != $etu->get_id())
							echo '<option value="'.$etu->get_id().'">'.$etu->get_nom().' '.$etu->get_prenom().'</option>';
					}
					echo '</select>
						  </div>
						  </td>';
					
					if($ta->get_auteur_tache() ==  $etuConnect->get_id() && !$premiere)
						echo '<td class="BMoins"><input type="button" value="-" onClick="enleveLigne(this,\'tabTache\')"/></td>';
				 
					echo '</tr>';
					
					$premiere = false;
				}
				 $_SESSION['idtache'] = $idtache;
					
	
			echo'<tr  id="ajoutTache">
			</tr>	
		<th colspan="5" class="trait3"><tr><tr/></th>	
		<th ><h4>Dépenses</h4></th>
			<tr> 
				<th class="BPlus">
					<input type="button" name="Plus" value="+" onClick="ajoutDepense()"/>
				</th>
				<th>
					<label for="NatureDepense">Nature</label>
				</th>
				<th>
					<label for="BudgetDepense">Budgets </label>
				</th>
				<th>
					<label for="Fournisseur">Fournisseur</label>
				</th>
			</tr>';
			
			if (!empty($d))
			{
				foreach($d as $dep)
				{
					echo '	<tr>
							<td></td>
							<td>';
				 	echo '<input type="text" name="NatureDepense[]" ';
				 	
				 	echo'class="obligatoire" value="'.$dep->get_libelle().'" onBlur="verifChamp(this)" onFocus="blanc(this)" />';
								 	
					echo '	</td>
							<td>';
								echo'<input type="text" name="BudgetDepense[]" ';
								
								echo'class="obligatoire" value="'.$dep->get_budget().'"';
									echo ' onBlur="verifChamp(this)" onFocus="blanc(this)"/>';
								
					echo '	</td>
							<td>';
							
					echo '<input type="text" name="Fournisseur[]" ';
					
					echo'class="obligatoire" value="'.$dep->get_fournisseur().'"';
					echo ' onBlur="verifChamp(this)" onFocus="blanc(this)"/>';
							
					echo '</td>
						  ';					
					if($dep->get_auteur_depense() ==  $etuConnect->get_id())
						echo '<td class="BMoins"><input type="button" value="-" onClick="enleveLigne(this,\'tabDepense\')"/></td>';
			 
					echo'</tr>';
				}
			}
			echo'<tr  id="ajoutDepense">
			</tr>
		<th colspan="5" class="trait3"><tr><tr/></th>	
		<th><h4>Recettes</h4></th>
			<tr>
				<th class="BPlus">
					<input type="button" name="Plus" value="+" onClick="ajoutRecette()"/>
				</th>
				<th>
					<label for="NatureRecette">Nature</label>
				</th>
				<th>
					<label for="BudgetsRecette">Budgets</label>
				</th>
			</tr>';
			
			if (!empty($r))
			{
				foreach($r as $rec)
				{		
					echo '<tr>
						  <td></td>
						  <td>';
					
					echo '<input type="text" name="NatureRecette[]" ';
					
					echo 'class="obligatoire" value="'.$rec->get_libelle().'" onBlur="verifChamp(this)" onFocus="blanc(this)"/>
						  </td>
						  <td>';
					
					echo '<input type="text" name="BudgetRecette[]" ';
					echo 'class="obligatoire" value="'.$rec->get_budget().'" onBlur="verifChamp(this)" onFocus="blanc(this)"/>
						  </td>
							<td></td>';
					
					if($ta->get_auteur_tache() ==  $etuConnect->get_id())
						echo '<td class="BMoins"><input type="button" value="-" onClick="enleveLigne(this,\'tabRecette\')"/></td>';
					
					echo '</tr>';
				}
			}
				echo'<tr  id="ajoutRecette">
			</tr>
		</table>
			<br/>
	<hr id="trait2"/>
	<table class="sansBord"><tr>';
	}
	else 
	{
		echo'<br/>
		<hr id="trait2"/>
		<table class="sansBord">
		<tr>
		<th><h4>Travail effectué</h4></th>
		<td>
		<textarea name="TravailEffectue" cols="100" rows="10">'.$fba->get_travailEffectue().'</textarea>
					</td>
				</tr><tr>
			<th colspan="5" class="trait3"><tr><tr/></th>';
	}
		?>
		
			<th><h4>Points positifs</h4></th>
			<td>
				<textarea name="PointPositif" cols="100" rows="10"><?php echo str_replace("<br/>", "", $fba->get_pointPositif());?></textarea>
			</td>
		</tr>
		<tr>
			<th colspan="5" class="trait3"><tr><tr/></th>
			<th><h4>Points négatifs</h4></th>
			<td>
				<textarea name="PointNegatif" cols="100" rows="10"><?php echo str_replace("<br/>", "", $fba->get_pointNegatif());;?></textarea>
			</td>
		</tr>
		<tr>
			<th colspan="5" class="trait3"><tr><tr/></th>
			<th><h4>Bon à savoir</h4></th>
			<td>
				<textarea name="BonASavoir" cols="100" rows="10"><?php echo str_replace("<br/>", "", $fba->get_bonASavoir());?></textarea>
			</td>
		</tr>
		<tr>
			<th colspan="5" class="trait3"><tr><tr/></th>
			<th><h4>Suggestions</h4></th>
			<td>
				<textarea name="Suggestion" cols="100" rows="10"><?php echo str_replace("<br/>", "", $fba->get_suggestion());?></textarea>
			</td>
			<td>
				<span id="erreur"></span>
			</td>
		</tr>
	</table>
	<p>
		<input class="Ligne2" type="submit" value="Envoyer" name="envoyerFicheADC" onClick = "return verifFormulaire()"/>
		<input class="Ligne2" type="submit" value="Retour" name="annuler"/>
	</p>
</form>